EmSAT Achieve Exam  >  EmSAT Achieve Questions  >  Output of following program#include<iostre... Start Learning for Free
Output of following program
#include<iostream>
using namespace std;
class Base
{
public:
    virtual void show() { cout<<" In Base \\n"; }
};
class Derived: public Base
{
public:
    void show() { cout<<"In Derived \\n"; }
};
int main(void)
{
    Base *bp, b;
    Derived d;
    bp = &d;
    bp->show();
    bp = &b;
    bp->show();
    return 0;
}
  • a)
    In Base 
    In Base 
  • b)
    In Base 
    In Derived
  • c)
    In Derived
    In Derived
  • d)
    In Derived
    In Base 
Correct answer is option 'D'. Can you explain this answer?
Most Upvoted Answer
Output of following program#include<iostream>using namespace std...
Initially base pointer points to a derived class object. Later it points to base class object,
Explore Courses for EmSAT Achieve exam

Top Courses for EmSAT Achieve

Question Description
Output of following program#include<iostream>using namespace std;class Base{public: virtual void show() { cout<<" In Base \\n"; }};class Derived: public Base{public: void show() { cout<<"In Derived \\n"; }};int main(void){ Base *bp, b; Derived d; bp = &d; bp->show(); bp = &b; bp->show(); return 0;}a)In BaseIn Baseb)In BaseIn Derivedc)In DerivedIn Derivedd)In DerivedIn BaseCorrect answer is option 'D'. Can you explain this answer? for EmSAT Achieve 2025 is part of EmSAT Achieve preparation. The Question and answers have been prepared according to the EmSAT Achieve exam syllabus. Information about Output of following program#include<iostream>using namespace std;class Base{public: virtual void show() { cout<<" In Base \\n"; }};class Derived: public Base{public: void show() { cout<<"In Derived \\n"; }};int main(void){ Base *bp, b; Derived d; bp = &d; bp->show(); bp = &b; bp->show(); return 0;}a)In BaseIn Baseb)In BaseIn Derivedc)In DerivedIn Derivedd)In DerivedIn BaseCorrect answer is option 'D'. Can you explain this answer? covers all topics & solutions for EmSAT Achieve 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Output of following program#include<iostream>using namespace std;class Base{public: virtual void show() { cout<<" In Base \\n"; }};class Derived: public Base{public: void show() { cout<<"In Derived \\n"; }};int main(void){ Base *bp, b; Derived d; bp = &d; bp->show(); bp = &b; bp->show(); return 0;}a)In BaseIn Baseb)In BaseIn Derivedc)In DerivedIn Derivedd)In DerivedIn BaseCorrect answer is option 'D'. Can you explain this answer?.
Solutions for Output of following program#include<iostream>using namespace std;class Base{public: virtual void show() { cout<<" In Base \\n"; }};class Derived: public Base{public: void show() { cout<<"In Derived \\n"; }};int main(void){ Base *bp, b; Derived d; bp = &d; bp->show(); bp = &b; bp->show(); return 0;}a)In BaseIn Baseb)In BaseIn Derivedc)In DerivedIn Derivedd)In DerivedIn BaseCorrect answer is option 'D'. Can you explain this answer? in English & in Hindi are available as part of our courses for EmSAT Achieve. Download more important topics, notes, lectures and mock test series for EmSAT Achieve Exam by signing up for free.
Here you can find the meaning of Output of following program#include<iostream>using namespace std;class Base{public: virtual void show() { cout<<" In Base \\n"; }};class Derived: public Base{public: void show() { cout<<"In Derived \\n"; }};int main(void){ Base *bp, b; Derived d; bp = &d; bp->show(); bp = &b; bp->show(); return 0;}a)In BaseIn Baseb)In BaseIn Derivedc)In DerivedIn Derivedd)In DerivedIn BaseCorrect answer is option 'D'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Output of following program#include<iostream>using namespace std;class Base{public: virtual void show() { cout<<" In Base \\n"; }};class Derived: public Base{public: void show() { cout<<"In Derived \\n"; }};int main(void){ Base *bp, b; Derived d; bp = &d; bp->show(); bp = &b; bp->show(); return 0;}a)In BaseIn Baseb)In BaseIn Derivedc)In DerivedIn Derivedd)In DerivedIn BaseCorrect answer is option 'D'. Can you explain this answer?, a detailed solution for Output of following program#include<iostream>using namespace std;class Base{public: virtual void show() { cout<<" In Base \\n"; }};class Derived: public Base{public: void show() { cout<<"In Derived \\n"; }};int main(void){ Base *bp, b; Derived d; bp = &d; bp->show(); bp = &b; bp->show(); return 0;}a)In BaseIn Baseb)In BaseIn Derivedc)In DerivedIn Derivedd)In DerivedIn BaseCorrect answer is option 'D'. Can you explain this answer? has been provided alongside types of Output of following program#include<iostream>using namespace std;class Base{public: virtual void show() { cout<<" In Base \\n"; }};class Derived: public Base{public: void show() { cout<<"In Derived \\n"; }};int main(void){ Base *bp, b; Derived d; bp = &d; bp->show(); bp = &b; bp->show(); return 0;}a)In BaseIn Baseb)In BaseIn Derivedc)In DerivedIn Derivedd)In DerivedIn BaseCorrect answer is option 'D'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Output of following program#include<iostream>using namespace std;class Base{public: virtual void show() { cout<<" In Base \\n"; }};class Derived: public Base{public: void show() { cout<<"In Derived \\n"; }};int main(void){ Base *bp, b; Derived d; bp = &d; bp->show(); bp = &b; bp->show(); return 0;}a)In BaseIn Baseb)In BaseIn Derivedc)In DerivedIn Derivedd)In DerivedIn BaseCorrect answer is option 'D'. Can you explain this answer? tests, examples and also practice EmSAT Achieve tests.
Explore Courses for EmSAT Achieve exam

Top Courses for EmSAT Achieve

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev